﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Utility.Web;
using Utility;
using XDeal.DAL.CustomEntities;
using XDeal.DAL.Entities;
using XDeal.DAL.Implements;

namespace XDeal.Common.Web
{
    /// <summary>
    /// Use as Session
    /// </summary>
    //Add 'GV' text after all of objects. Example: CompanyGV
    public class GlobalVariables
    {   
        /// <summary>
        /// Count Number Of Login Fail
        /// </summary>
        public static int NumberOfLoginGV
        {
            get
            {
                if (WebSession.Get("NumberOfLoginGV") == null)
                    return 0;
                return ConvertManage.ConvertToInt(WebSession.Get("NumberOfLoginGV"), 0);
            }
            set
            {
                if (value == 0)
                    WebSession.Remove("NumberOfLoginGV");
                else
                    WebSession.Set("NumberOfLoginGV", value);
            }
        }


        /// <summary>
        /// Creat session to save order
        /// </summary>
        public static CusOrderBO OrderDeals
        {
            get
            {
                if (WebSession.Get("OrderDeals") == null)
                    return null;
                return (CusOrderBO)(WebSession.Get("OrderDeals"));
            }
            set
            {
                if (value == null)
                    WebSession.Remove("OrderDeals");
                else
                    WebSession.Set("OrderDeals", value);
            }
        }

        /// <summary>
        /// Creat session to save Customer
        /// </summary>
        public static Customer Customer
        {
            get
            {
                if (WebSession.Get("Customer") == null)
                    return null;
                return (Customer)(WebSession.Get("Customer"));
            }
            set
            {
                if (value == null)
                    WebSession.Remove("Customer");
                else
                    WebSession.Set("Customer", value);
            }
        }

    }
}